package com.bupt.fmmall.service.Impl;

import com.bupt.fmmall.dao.ComplaintDao;
import com.bupt.fmmall.entity.Complaint;
import com.bupt.fmmall.service.ComplaintService;
import com.bupt.fmmall.vo.ResultVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ComplaintServiceImpl implements ComplaintService {
    @Resource
    ComplaintDao complaintDao;
    @Override
    public ResultVO customerComplaint(Complaint complaint) {
        int i=complaintDao.insertComplaint(complaint);
        if (i>0){
            return new ResultVO(200,"success",null);
        }else {
            return new ResultVO(601,"投诉失败",null);
        }
    }

    @Override
    public ResultVO customerWithdrawComplaint(int complaintId) {
        int i=complaintDao.deleteComplaint(complaintId);
        if (i>0){
            return new ResultVO(200,"success",null);
        }else {
            return new ResultVO(601,"删除投诉失败",null);
        }
    }

    @Override
    public ResultVO customerViewAllComplaints(String customerUserName) {
        List<Complaint> list=complaintDao.selectComplaintByName(customerUserName);
        return new ResultVO(200,"success",list);
    }

    @Override
    public List<Complaint> adminViewAllComplaints() {
        return null;
    }

    @Override
    public void adminDeleteComplaint(int complaintId) {

    }
}
